﻿Imports DTO
Imports DAO
Imports BUS

Public Class frmCapNhatBangThamSo : Inherits DevComponents.DotNetBar.Office2007Form

    Private Sub btnThoat_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Me.Close()
    End Sub

    Private Sub frmCapNhatBangThamSo_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        dtiNgayThang.Value = DateTime.Now
        txtGiaTriThe.Enabled = False
        txtSoLoaiDocGia.Enabled = False
        txtSoLuongBangCap.Enabled = False
        txtSoLuongBoPhan.Enabled = False
        txtSoLuongChucVu.Enabled = False
        txtSoLuongMuonToiDa.Enabled = False
        txtSoLuongTheLoaiSach.Enabled = False
        txtSoLyDoThanhLy.Enabled = False
        txtThoiHanMuonToiDa.Enabled = False
        txtThoiHanSach.Enabled = False
        txtTienPhatTraTreMoiNgay.Enabled = False
        txtTuoiLonNhat.Enabled = False
        txtTuoiNhoNhat.Enabled = False

        Dim tsbus As New CThamSoBUS()
        Dim tsdto As CThamSoDTO = tsbus.LoadDanhSachThamSo()
        txtGiaTriThe.Text = tsdto.GiaTriThe
        txtSoLoaiDocGia.Text = tsdto.SoLoaiDocGia
        txtSoLuongBangCap.Text = tsdto.SoLuongBangCap
        txtSoLuongBoPhan.Text = tsdto.SoLuongBoPhan
        txtSoLuongChucVu.Text = tsdto.SoLuongChucVu
        txtSoLuongMuonToiDa.Text = tsdto.SoLuongMuonToiDa
        txtSoLuongTheLoaiSach.Text = tsdto.SoLuongTheLoaiSach
        txtSoLyDoThanhLy.Text = tsdto.SoLyDoThanhLy
        txtThoiHanMuonToiDa.Text = tsdto.ThoiHanMuonToiDa
        txtThoiHanSach.Text = tsdto.ThoiHanSach
        txtTienPhatTraTreMoiNgay.Text = tsdto.TienPhatTraTreMoiNgay
        txtTuoiLonNhat.Text = tsdto.TuoiLonNhat
        txtTuoiNhoNhat.Text = tsdto.TuoiNhoNhat
    End Sub





    Private Sub btnCapNhat_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCapNhat.Click
        Dim ctsbus As New CThamSoBUS()

        If (cbGiaTriThe.Checked = True) Then
            Dim gtt As Integer

            If (Integer.TryParse(txtGiaTriThe.Text, gtt)) Then
                ctsbus.UpdateGiaTriThe(gtt)
            End If
        End If

        If (cbSoLoaiDocGia.Checked = True) Then
            Dim sldg As Integer
            If (Integer.TryParse(txtSoLoaiDocGia.Text, sldg)) Then
                ctsbus.UpdateSoLoaiDocGia(sldg)
            End If
        End If

        If (cbSoLuongBangCap.Checked = True) Then
            Dim slbc As Integer
            If (Integer.TryParse(txtSoLuongBangCap.Text, slbc)) Then
                ctsbus.UpdateSoLuongBangCap(slbc)
            End If
        End If

        If (cbSoLuongBoPhan.Checked = True) Then
            Dim slbp As Integer
            If (Integer.TryParse(txtSoLuongBoPhan.Text, slbp)) Then
                ctsbus.UpdateSoLuongBoPhan(slbp)
            End If
        End If

        If (cbSoLuongChucVu.Checked = True) Then
            Dim slcv As Integer
            If (Integer.TryParse(txtSoLuongChucVu.Text, slcv)) Then
                ctsbus.UpdateSoLuongChucVu(slcv)
            End If
        End If

        If (cbSoLuongMuonToiDa.Checked = True) Then
            Dim slmtd As Integer
            If (Integer.TryParse(txtSoLuongMuonToiDa.Text, slmtd)) Then
                ctsbus.UpdateSoLuongMuonToiDa(slmtd)
            End If
        End If


        If (cbSoLuongTheLoaiSach.Checked = True) Then
            Dim sltls As Integer
            If (Integer.TryParse(txtSoLuongTheLoaiSach.Text, sltls)) Then
                ctsbus.UpdateSoLuongTheLoaiSach(sltls)
            End If
        End If

        If (cbSoLyDoThanhLy.Checked = True) Then
            Dim sldtl As Integer
            If (Integer.TryParse(txtSoLyDoThanhLy.Text, sldtl)) Then
                ctsbus.UpdateSoLyDoThanhLy(sldtl)
            End If
        End If

        If (cbThoiHanMuonToiDa.Checked = True) Then
            Dim thmtd As Integer
            If (Integer.TryParse(txtThoiHanMuonToiDa.Text, thmtd)) Then
                ctsbus.UpdateThoiHanMuonToiDa(thmtd)
            End If
        End If

        If (cbThoiHanSach.Checked = True) Then
            Dim ths As Integer
            If (Integer.TryParse(txtThoiHanSach.Text, ths)) Then
                ctsbus.UpdateThoiHanSach(ths)
            End If
        End If

        If (cbTienPhatTraTreMoiNgay.Checked = True) Then
            Dim tptrmn As Integer
            If (Integer.TryParse(txtTienPhatTraTreMoiNgay.Text, tptrmn)) Then
                ctsbus.UpdateTienPhatTraTreMoiNgay(tptrmn)
            End If
        End If

        If (cbTuoiLonNhat.Checked = True) Then
            Dim tln As Integer
            If (Integer.TryParse(txtTuoiLonNhat.Text, tln)) Then
                ctsbus.UpdateTuoiLonNhat(tln)
            End If
        End If

        If (cbTuoiNhoNhat.Checked = True) Then
            Dim tnn As Integer
            If (Integer.TryParse(txtTuoiNhoNhat.Text, tnn)) Then
                ctsbus.UpdateTuoiNhoNhat(tnn)
            End If
        End If
    End Sub

    Private Sub cbTuoiLonNhat_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbTuoiLonNhat.CheckedChanged
        txtTuoiLonNhat.Enabled = cbTuoiLonNhat.Checked
    End Sub


    Private Sub cbTuoiNhoNhat_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbTuoiNhoNhat.CheckedChanged
        txtTuoiNhoNhat.Enabled = cbTuoiNhoNhat.Checked
    End Sub


    Private Sub cbGiaTriThe_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbGiaTriThe.CheckedChanged
        txtGiaTriThe.Enabled = cbGiaTriThe.Checked
    End Sub


    Private Sub cbThoiHanSach_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbThoiHanSach.CheckedChanged
        txtThoiHanSach.Enabled = cbThoiHanSach.Checked
    End Sub


    Private Sub cbSoLuongMuonToiDa_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbSoLuongMuonToiDa.CheckedChanged
        txtSoLuongMuonToiDa.Enabled = cbSoLuongMuonToiDa.Checked
    End Sub


    Private Sub cbThoiHanMuonToiDa_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbThoiHanMuonToiDa.CheckedChanged
        txtThoiHanMuonToiDa.Enabled = cbThoiHanMuonToiDa.Checked
    End Sub


    Private Sub cbTienPhatTraTreMoiNgay_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbTienPhatTraTreMoiNgay.CheckedChanged
        txtTienPhatTraTreMoiNgay.Enabled = cbTienPhatTraTreMoiNgay.Checked
    End Sub


    Private Sub cbSoLuongBangCap_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbSoLuongBangCap.CheckedChanged
        txtSoLuongBangCap.Enabled = cbSoLuongBangCap.Checked
    End Sub


    Private Sub cbSoLuongBoPhan_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbSoLuongBoPhan.CheckedChanged
        txtSoLuongBoPhan.Enabled = cbSoLuongBoPhan.Checked
    End Sub


    Private Sub cbSoLuongChucVu_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbSoLuongChucVu.CheckedChanged
        txtSoLuongChucVu.Enabled = cbSoLuongChucVu.Checked
    End Sub


    Private Sub cbSoLoaiDocGia_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbSoLoaiDocGia.CheckedChanged
        txtSoLoaiDocGia.Enabled = cbSoLoaiDocGia.Checked
    End Sub


    Private Sub cbSoLuongTheLoaiSach_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbSoLuongTheLoaiSach.CheckedChanged
        txtSoLuongTheLoaiSach.Enabled = cbSoLuongTheLoaiSach.Checked
    End Sub


    Private Sub cbSoLyDoThanhLy_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbSoLyDoThanhLy.CheckedChanged
        txtSoLyDoThanhLy.Enabled = cbSoLyDoThanhLy.Checked
    End Sub
End Class